﻿// This project type requires the F# PowerPack at http://fsharppowerpack.codeplex.com/releases
// Learn more about F# at http://fsharp.net
// Original project template by Jomo Fisher based on work of Brian McNamara, Don Syme and Matt Valerio
// This posting is provided "AS IS" with no warranties, and confers no rights.

open System
open Microsoft.FSharp.Text.Lexing

open Lilium.AG.Abl
open Lilium.AG.Abl.Lexer
open Lilium.AG.Abl.Parser

let test str = 
    printf "%s : " str
    let lexbuff = LexBuffer<char>.FromString(str)
    let res = parse tokenize lexbuff
    printfn "done"

test "Nill | lenght"
test "Cons (_, tail) | lenght "
test "Cons (_, tail) as test | lenght "
test "Cons (_, tail) | lenght <- tail.length"
test "Cons (value, tail) | sum <- value tail.sum"
test "List list as test | list.length list.sum -> list.avg"

(*
let rec readAndProcess() =
    printf ":"
    match Console.ReadLine() with
    | "quit" -> ()
    | expr ->
        try
            printfn "Lexing [%s]" expr
            let lexbuff = LexBuffer<char>.FromString(expr)
            
            printfn "Parsing..."
            let equation = start1 tokenize lexbuff
            
            printfn "Evaluating Equation..."
            let result = evalEquation equation
            
            printfn "Result: %s" (result.ToString())
            
        with ex ->
            printfn "Unhandled Exception: %s" ex.Message

        readAndProcess()

readAndProcess()
*)